<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>Title</title>
</head>
<body>
<article class="page-container">
    <form action="" method="get" class="form form-horizontal" id="form-admin-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>操作员编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" style="background:#F5F5F5" class="input-text" readonly="readonly" value="${map.get('db1')[0].VALUE01}" id="VALUE01"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>负责人：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" autocomplete="off" value="${map.get('db1')[0].VALUE02}" id="VALUE02">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">联系电话：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="${map.get('db1')[0].VALUE03}" id="VALUE03">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">所属部门：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
			        <select class="select" id="VALUE04" size="1">
                        <C:forEach items="${map.get('db2')}" var="t_two" >
                            <c:if test="${t_two.VALUE02==map.get('db1')[0].VALUE04}">
                                <option value="${t_two.VALUE01}" selected="selected">${t_two.VALUE02}</option>
                            </c:if>
                            <c:if test="${t_two.VALUE02!=map.get('db1')[0].VALUE04}">
                                <option value="${t_two.VALUE01}">${t_two.VALUE02}</option>
                            </c:if>
                        </C:forEach>
			        </select>
			    </span>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">所属角色：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
			        <select class="select" id="VALUE05" size="1">
                        <option value=""></option>
                        <C:forEach items="${map.get('db3')}" var="t_thr" >
                            <c:if test="${t_thr.VALUE01==map.get('db1')[0].VALUE05}">
                                <option value="${t_thr.VALUE01}" selected="selected">${t_thr.VALUE02}</option>
                            </c:if>
                            <c:if test="${t_thr.VALUE01!=map.get('db1')[0].VALUE05}">
                                <option value="${t_thr.VALUE01}">${t_thr.VALUE02}</option>
                            </c:if>
                        </C:forEach>
			        </select>
			    </span>
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">

    $(document).ajaxComplete(function(event, xhr, settings) {
        //从http头信息取出 在filter定义的sessionstatus，判断是否是 timeout
        if(xhr.getResponseHeader("sessionstatus")==="timeout"){
            //从http头信息取出登录的url ＝ loginPath
            if(xhr.getResponseHeader("loginPath")){
                window.location.replace(xhr.getResponseHeader("loginPath"));
            }
        }
    });

    $(function()
    {
        $("#form-admin-add").validate({
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var LS_VALUE01  = $("#VALUE01").val();
                var LS_VALUE02  = $("#VALUE02").val();
                var LS_VALUE03  = $("#VALUE03").val();
                var LS_VALUE04  = $("#VALUE04").val();
                var LS_VALUE05  = $("#VALUE05").val();
                var ls_opid = "${sessionOpid}";
                if (!ls_opid)
                {
                    layer.msg("请重新登录系统！", {icon: 0, time: 1000});
                    return;
                }

                if (LS_VALUE02.length === 0)
                {
                    layer.msg("请输入负责人姓名", {icon: 2, time: 1500});
                    return;
                }

                if (LS_VALUE05.length === 0)
                {
                    layer.msg("请选择人员所属角色", {icon: 2, time: 1500});
                    return;
                }

                layer.confirm('确认要继续操作吗？', {icon: 3},function()
                {
                    $.ajax({                            //该方法提交，在前端获取控件的值去进行提交， 两种方法就是前段和后端的区别
                        type: 'post',
                        url: "com",
                        data: {
                            URL: '',
                            CMD: 'ZH',
                            VALUE01: LS_VALUE01,
                            VALUE02: LS_VALUE02,
                            VALUE03: LS_VALUE03,
                            VALUE04: LS_VALUE04,
                            VALUE05: LS_VALUE05,
                            VALUE06: ls_opid
                        },
                        async: false,
                        success: function (data) {
                            var jsonobj = JSON.parse(data);
                            var json1 = jsonobj.db1;
                            if (json1[0].VALUE01.toString() === 'ZZ00') {
                                layer.msg('数据库操作完毕!', {icon: 1, time: 1000}, function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.f_getinfo();
                                    parent.layer.close(index);
                                });
                            } else {
                                layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 1500, area: ['200px', '65px']}, function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                });
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('网络异常错误', {icon: 1, time: 1000});
                        }
                    });
                })
            }
        });
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
